<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta content="IE=8" http-equiv="X-UA-Compatible" />
    <title>栏目授权--选择栏目</title>
    {$QPath}
    <link rel="stylesheet" type="text/css" href="__TMPL__../Admin/Public/base.css" />
    <style type="text/css">
        .grid input{margin-right:2px;}
        .grid label{margin-right:12px;}
    </style>
    <script type="text/javascript" src="__TMPL__../Admin/Public/mootools.js"></script>
    <script type="text/javascript" src="__TMPL__../Admin/Public/base.js"></script>
</head>
<body>
    <div id="container">
        <table class="tabmenu" cellspacing="0">
            <tbody>
                <tr>
                    <td class="wedge">&nbsp;</td>
                    <td class="wmenu"><a href="__URL__/index">栏目列表</a></td>
                    <td class="wmenu"><a href="__URL__/add">添加栏目</a></td>
                    <td class="wmenu here">栏目授权</td>
                    <td>&nbsp;</td>
                </tr>
            </tbody>
        </table>
        <div class="main">
                <p class="editpage finder">
                    选择授权栏目<span>(当前授权用户：<b>{$uarr[1]}</b>)</span>
                </p>
            <ul class="fnc">
                <li><button type="button" class="btn primary" onclick="doAction('allocate')">保存</button></li>
                <li><button type="button" class="btn" onclick="doAction('back')">返回</button></li>
            </ul>
            <form method="post" action="__URL__">
                <input type="hidden" name="a" />
                <input type="hidden" name="step" value="choosecategory" />
                <input type="hidden" name="uid" value="{$uarr[0]}" />
                <table class="data">
                    <thead>
                        <tr>
                            <th>栏目名称</th>
                            <th>操作权限</th>
                        </tr>
                    </thead>
                    <tbody class="grid" id="catesBody">
                        <present name="cates">
                            <?php
                            $nbsp=array();
                            $nbsp[0]="";
                            $nbsp[1]="&nbsp;";

                            function getNbsp($level,&$nbsp){
                                if( ! array_key_exists($level,$nbsp)){
                                    $last=$nbsp[intval($level)-1];
                                    $nbsp[$level]=$last.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                                }
                                return $nbsp[$level];
                            }
                            ?>
                            <iterate name="cates" id="vo">
                                <tr>
                                    <td>
                                        {$vo['level']|getNbsp=###,$nbsp}
                                        <input id="s{$vo['id']}" type="checkbox" name="sid[]" value="{$vo['id']}"/>
                                        {$vo['name']}
                                    </td>
                                    <td>
                                        <input id="pk{$vo['id']}" type="checkbox" name="range[]" value="{$vo['id']}"/><label for="pk{$vo['id']}">全部文档</label>
                                    </td>
                                </tr>
                            </iterate>
                            <tr style="display:none">
                                <td><input id="s0" type="checkbox" name="sid[]" checked value="0"/></td>
                                <td></td>
                            </tr>
                        <else/>
                            <tr class="notfound">
                                <td colspan="20">没有记录</td>
                            </tr>
                        </present>
                    </tbody>
                </table>
            </form>
            <ul class="fnc">
                <li><button type="button" class="btn primary" onclick="doAction('allocate')">保存</button></li>
                <li><button type="button" class="btn" onclick="doAction('back')">返回</button></li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        $(window).addEvent('domready',function(){
            //禁止事件的传播
            $("catesBody").getElements("input").each(function(ips){
                if('range[]'==ips.getProperty('name')){
                    ips.addEvent('click',function(event){
                        event.stopPropagation();
                    });
                    ips.getNext().addEvent('click',function(event){
                        event.stopPropagation();
                    });
                }
            });
            //初始用户已有授权项目
            var tmp;
            <iterate name="allocate" id="vo">
            tmp=$("s{$vo['category']}");
            tmp.checked=true;
            tmp.parentNode.parentNode.className='rowChecked';
            if('{$vo['allocate']}'=='y'){
                $("pk{$vo['category']}").checked=true;
            }
           </iterate>
        });
    </script>
</body>
</html>